package com.sylli.oeuf.server.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sylli.oeuf.server.db.DatabaseProviderBundle;
import com.sylli.oeuf.server.object.transferable.CharacterGeneralInfoTO;
import com.sylli.oeuf.server.object.transferable.CharacterPostDataTO;
import com.sylli.oeuf.server.object.transferable.PostConsoleResponseTO;
import com.sylli.oeuf.server.object.transferable.PostResponseTO;
import com.sylli.oeuf.server.object.transferable.WrappedCharacterInfoTO;

public class ConsoleService extends BasedService {
	
	private static Logger log = LoggerFactory.getLogger( "service.console" );
	
	private DatabaseProviderBundle providers = DatabaseProviderBundle.getInstance();
	
	public PostConsoleResponseTO post(String s) {
		PostConsoleResponseTO _resp = new PostConsoleResponseTO();
		try {
			String cmd = s.split(" ")[0];
			if (cmd.equals("/heal")) {
				WrappedCharacterInfoTO wci = sessionManager.getWrappedCharacterInfo();
				CharacterPostDataTO cpd = wci.getPostData();
				CharacterGeneralInfoTO cgi = wci.getGeneralInfo();
				cpd.setCurrentHp(cgi.getMaxHp());
				providers.charPostData.update(cpd);
			} else if (cmd.equals("")) {
				
			} else if (cmd.equals("")) {
				
			}
		} catch (Exception e) {
			log.error("Error: " + e.getMessage());
			_resp.setResponseContent(PostResponseTO.POSTRESP_CRITCAL, 
					"$System Exception: " + e.getMessage());
			return _resp;
		}
		return _resp;
	}
	
}
